package iterator.improve;

import java.util.Iterator;
import java.util.List;

/**
 * @author Fengdong.Duan
 * @create 2023/11/27 10:43
 */
public class InfoColleageIterator implements Iterator<Department> {

    private final List<Department> departments;
    private int index = 0;

    public InfoColleageIterator(List<Department> departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        return !departments.isEmpty() && index + 1 <= departments.size();
    }

    @Override
    public Department next() {
        Department department = departments.get(index);
        index++;
        return department;
    }
}
